package org.kabeja.dxf.entity;

import org.kabeja.dxf.DXFConstants;
import org.kabeja.dxf.helpers.Point;
import org.kabeja.dxf.objects.DXFObject;

/**
 * @author shutao
 * @since 2022/4/28 14:31
 */
public class DXFSpatialFilter extends DXFObject {

    protected int pointNumber;
    protected Point boundaryPoint = new Point();
    protected Point normalStretch = new Point();
    protected Point localPoint = new Point();

    protected boolean clippingBoundaries;
    protected boolean clippingFront;
    protected double clippingFrontDistance;
    protected boolean clippingBack;
    protected double clippingBackDistance;

    protected double[][] inverseMatrix = new double[4][3];
    protected double[][] matrix = new double[4][3];
    private int count = 0;

    @Override
    public String getObjectType() {
        return DXFConstants.OBJECT_TYPE_SPATIAL_FILTER;
    }

    public int getPointNumber() {
        return pointNumber;
    }

    public void setPointNumber(int pointNumber) {
        this.pointNumber = pointNumber;
    }

    public Point getBoundaryPoint() {
        return this.boundaryPoint;
    }

    public void setBoundaryPointX(double var) {
        this.boundaryPoint.setX(var);
    }

    public void setBoundaryPointY(double var) {
        this.boundaryPoint.setY(var);
    }

    public Point getNormalStretch() {
        return this.normalStretch;
    }

    public void setNormalStretchX(double var) {
        this.normalStretch.setX(var);
    }

    public void setNormalStretchY(double var) {
        this.normalStretch.setY(var);
    }

    public Point getLocalPoint() {
        return this.localPoint;
    }

    public void setLocalPointX(double var) {
        this.localPoint.setX(var);
    }

    public void setLocalPointY(double var) {
        this.localPoint.setY(var);
    }

    public boolean isClippingBoundaries() {
        return clippingBoundaries;
    }

    public void setClippingBoundaries(int var) {
        this.clippingBoundaries = var == 1;
    }

    public boolean isClippingFront() {
        return clippingFront;
    }

    public void setClippingFront(int var) {
        this.clippingFront = var == 1;
    }

    public boolean isClippingBack() {
        return clippingBack;
    }

    public void setClippingBack(int var) {
        this.clippingBack = var == 1;
    }

    public double getClippingFrontDistance() {
        return clippingFrontDistance;
    }

    public void setClippingFrontDistance(double clippingFrontDistance) {
        this.clippingFrontDistance = clippingFrontDistance;
    }

    public double getClippingBackDistance() {
        return clippingBackDistance;
    }

    public void setClippingBackDistance(double clippingBackDistance) {
        this.clippingBackDistance = clippingBackDistance;
    }

    public void setMatrix(double var) {
        if (count < 12) {
            int dim1 = count / 3;
            int dim2 = count % 3;
            this.inverseMatrix[dim1][dim2] = var;
        } else {
            int dim1 = count / 3 - 4;
            int dim2 = count % 3;
            this.matrix[dim1][dim2] = var;
        }
        count++;
    }

    public double[][] getInverseMatrix() {
        return this.inverseMatrix;
    }

    public double[][] getMatrix() {
        return this.matrix;
    }
}
